package com.hylz.nbs.listener;

import java.io.File;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import com.hylz.nbs.util.StringUtil;

@WebListener
public class CreateUploadPathListener implements ServletContextListener {
	@Override
	public void contextInitialized(ServletContextEvent arg) {
		String path = "pics";
		String temp = arg.getServletContext().getInitParameter("uploadPath");
		if(!StringUtil.checkNull(temp)) {
			path = temp;
		}
		
		String basePath = arg.getServletContext().getRealPath("/");
		File fl = new File(basePath,"../" + path);
		if(fl.exists()) {
			return;
		}
		fl.mkdirs(); //创建目录
	}
}
